package com.un10.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.un10.entity.Eventcommodity;
import com.un10.service.EventcommodityService;
import com.un10.util.Result;
@Controller
public class EventcommodityController {

	@Autowired
	EventcommodityService EventcommodityService;

	@RequestMapping("/houtai/getAllEventcommodity")
	@ResponseBody
	public Object getAllEventcommodity(@RequestParam("page") int page, @RequestParam("limit") int limit,
			@RequestParam("proName") String proName) {

		List<Eventcommodity> user = EventcommodityService.findAllEventcommodity((page - 1) * limit, limit, proName);

		if (proName == null || proName == "") {
			proName = null;
		}
		int count = EventcommodityService.getCount();
		System.out.println(proName);
		com.un10.util.Result res = new com.un10.util.Result(0, "", count, user);
		return res;
	}

	@RequestMapping("/houtai/eventcommodityadd")
	@ResponseBody
	public Object activitylistadd(@RequestParam Map<String, Object> map) {

		System.out.println(map.get("proName"));
		int i = EventcommodityService.findEventcommodityAdd(map);
		Result res = new Result(0, "", i, true);
		return res;
	}

	@RequestMapping("/houtai/EventcommodityUpdate")
	@ResponseBody
	public Object updateActivitylist(@RequestParam Map<String, Object> map) {

		int i = EventcommodityService.findEventcommodityUpdate(map);
		Result res = new Result(0, "", i, true);
		return res;
	}

	@RequestMapping("/houtai/eventcommoditydelete")
	@ResponseBody
	public Object activitylistdelete(@RequestParam("evID") Integer evID) {
		int i = EventcommodityService.findEventcommodityDelete(evID);
		Result res = new Result(0, "", i, true);
		return res;
	}
}
